package com.lagou.redis;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

public class JedisTest {
    public static void main(String[] args) {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxIdle(5000);
        config.setMaxWaitMillis(50000);
        config.setMaxTotal(5000);
        Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
        jedisClusterNode.add(new HostAndPort("106.75.35.118", 7001));
//        jedisClusterNode.add(new HostAndPort("106.75.35.118", 7002));
//        jedisClusterNode.add(new HostAndPort("106.75.35.118", 7003));
//        jedisClusterNode.add(new HostAndPort("106.75.35.118", 7004));
//        jedisClusterNode.add(new HostAndPort("106.75.35.118", 7005));
//        jedisClusterNode.add(new HostAndPort("106.75.35.118", 7006));
//        jedisClusterNode.add(new HostAndPort("106.75.35.118", 7007));
//        jedisClusterNode.add(new HostAndPort("106.75.35.118", 7008));
        JedisCluster jcd = new JedisCluster(jedisClusterNode, config);
        String result = jcd.set("name:001","zhangfei");
        System.out.println("set result = " + result);   //输出： set result = OK
        String value = jcd.get("name:001");
        System.out.println("get value = " + value);     //输出： get value = zhangfei
    }
}
